/**
	镜像服务器相关接口
 */
package hard

import (
	. "bc/util"
	"strings"
)

type storage struct {

}
/**
	删除镜像服务器
 */
func (c *storage) DeleteBackupStorage(uuid string,del_mode string,h map[string]string) (string,error) {

	url := Config.Zstack.ApiUrl + "/v1/backup-storage/{uuid}?deleteMode={deleteMode}"
	url = strings.Replace(url,"{uuid}",uuid,1)
	url = strings.Replace(url,"{deleteMode}",del_mode,1)

	res ,err := Curl.Url(url).Header(h).DELETE()
	return res,err

}
/**
	查询镜像服务器
 */
func (c *storage) QueryBackupStorage(uuid string,h map[string]string) (string,error) {

	url := Config.Zstack.ApiUrl + "/v1/backup-storage/{uuid}"
	url = strings.Replace(url,"{uuid}",uuid,1)
	res,err := Curl.Url(url).Header(h).GET()
	return res,err

}
/**
	重连镜像服务器
 */
func (c *storage) ReconnectBackupStorage(uuid string,h map[string]string,b string) (string,error) {

	url := Config.Zstack.ApiUrl + "/v1/backup-storage/{uuid}/actions"
	url = strings.Replace(url,"{uuid}",uuid,1)
	res ,err:= Curl.Url(url).Header(h).Body(b).PUT()
	return res,err

}
/**
	更改镜像服务器可用状态
 */
func (c *storage) ChangeBackupStorageState(uuid string,h map[string]string,b string) (string,error) {

	url := Config.Zstack.ApiUrl + "/v1/backup-storage/{uuid}/actions"
	url = strings.Replace(url,"{uuid}",uuid,1)
	res ,err := Curl.Url(url).Header(h).Body(b).PUT()
	return res,err
}
/**
	获取镜像服务器存储容量
 */
func (c *storage) GetBackupStorageCapacity(h map[string]string) (string,error) {

	url := Config.Zstack.ApiUrl + "/v1/backup-storage/capacities"
	res,err := Curl.Url(url).Header(h).GET()
	return res,err

}
/**
	获取镜像服务器类型列表
 */
func (c *storage) GetBackupStorageTypes(h map[string]string) (string,error) {

	url := Config.Zstack.ApiUrl + "/v1/backup-storage/types"
	res,err := Curl.Url(url).Header(h).GET()
	return res,err

}
var Storage = &storage{}
